home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRAPHICS / TS32 / TS32.ZIP / Grafix.int < prev    next >
Text File  |  1996-03-21  |  4KB  |  114 lines

  1. unit Grafix;
  2.  
  3. (*********************************************
  4. Custom graphics classes and drawing routines.
  5. *********************************************)
  6.  
  7. interface
  8.  
  9. uses
  10.   Windows, SysUtils, Classes;
  11.  
  12. const
  13.   PI =  3.14159265359;
  14.  
  15. type
  16.  
  17.   TDIBOrientation = ( orAuto, orTopDown, orBottomUp );
  18.   TDegree = 0..360;
  19.  
  20.   TVertex = class( TObject )
  21.   private
  22.      FX, FY: integer;
  23.   protected
  24.      function GetPoint: TPoint;
  25.   public
  26.      property X: integer read FX write FX;
  27.      property Y: integer read FY write FY;
  28.      constructor CreateVertex( nX, nY: integer );
  29.      property Point: TPoint read GetPoint;
  30.   end;
  31.  
  32.   TRectangle = class( TObject )
  33.   private
  34.      FLeft: integer;
  35.      FRight: integer;
  36.      FTop: integer;
  37.      FBottom: integer;
  38.   protected
  39.      function GetHeight: integer;
  40.      function GetRect: TRect;
  41.      function GetWidth: integer;
  42.   public
  43.      constructor CreateRectangle( l, t, r, b: integer );
  44.      constructor CreateFromRect( rect: TRect );
  45.      property Height: integer read GetHeight;
  46.      property Left: integer read FLeft write FLeft;
  47.      property Top: integer read FTop write FTop;
  48.      property Right: integer read FRight write FRight;
  49.      property Bottom: integer read FBottom write FBottom;
  50.      property Rect: TRect read GetRect;
  51.      property Width: integer read GetWidth;
  52.   end;
  53.  
  54.   TPolygon = class( TObject )
  55.   private
  56.      FClosed: boolean;
  57.   protected
  58.      lstVertices: TList;
  59.      function GetNum: integer;
  60.      function GetVertex( n: integer ): TVertex;
  61.   public
  62.      property Closed: boolean read FClosed write FClosed;
  63.      constructor Create;
  64.      destructor Destroy; override;
  65.      procedure Assign( p: TPolygon );
  66.      procedure AddVertex( v: TVertex );
  67.      procedure Rotate( Degrees: TDegree );
  68.      property VertexCount: integer read GetNum;
  69.      property Vertex[n: integer]: TVertex read GetVertex;
  70.   end;
  71.  
  72.   TFillElement = class( TObject )
  73.   private
  74.   protected
  75.   public
  76.      myLx, myLy: integer;
  77.      dadLx, dadLy: integer;
  78.      myY: integer;
  79.      myDirection: integer;
  80.   end;
  81.  
  82. (***************************************************
  83. Graphics routines
  84. ***************************************************)
  85. function ClipLine( var x1, y1, x2, y2: integer; const rect: TRect ): boolean;
  86. procedure CopyBlock( pSrc, pDest: pointer; nSrcWidth, nSrcHeight: integer;
  87.   nSrcBlockWidth, nSrcBlockHeight: integer; nSrcX, nSrcY: integer; nDestWidth,
  88.   nDestHeight: integer; nDestX, nDestY: integer; nTransColor: byte; OrSrc,
  89.   OrDest: TDIBOrientation );
  90. procedure DrawCircle( pDest: pointer; x, y, nRadius, nDestWidth, nDestHeight: integer;
  91.   nColor: byte );
  92. procedure DrawDIB( pSrc, pDest: pointer; nSrcWidth, nSrcHeight, nDestWidth,
  93.   nDestX, nDestY: integer; nTrans: byte; nOrientation: byte ); stdcall; assembler;
  94. procedure DrawLine( p: pointer; x1, y1, x2, y2, nDestWidth: integer; nColor: byte ); stdcall; assembler;
  95. procedure DrawLineThick( p: pointer; x1, y1, x2, y2, nDestWidth, nDestHeight: integer;
  96.   nColor, nThickness: byte );
  97. procedure DumpDIB( pSrc, pDest: pointer; nSrcWidth, nSrcHeight: integer;
  98.   nOrientation: byte ); stdcall; assembler;
  99. procedure FillBlock( pDest: pointer; nBlockWidth, nBlockHeight,
  100.   nDestWidth, nDestHeight, nDestX, nDestY: integer;
  101.   nColor: byte; OrDest: TDIBOrientation );
  102. procedure FillMem( p: pointer; nBytes: integer; nVal: byte ); stdcall; assembler;
  103. function PointInPolygon( poly: TPolygon; pt: TPoint ): boolean;
  104. function IntToDegree( n: integer ): TDegree;
  105.  
  106. (***************************************************
  107. The following arrays are lookup tables of common
  108. trig functions.
  109. ***************************************************)
  110. var
  111.   lkupSin: array[TDegree] of single;
  112.   lkupCos: array[TDegree] of single;
  113.   lkupArcTan: array[TDegree] of single;
  114.